package com.newer.his.BasicData.controller;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.newer.his.common.entity.Checkout;
import com.newer.his.common.mapper.CheckoutMapper;

/**
 * 医技项目和 控制器
 * @author Tang
 *
 */
@RestController
@RequestMapping("/checkout")
public class CheckoutController {
	
	
	@Autowired
	CheckoutMapper mapper;
	
	
	@GetMapping
	public List<Checkout> getAllCheckout() {
		return mapper.findAll();
		
	}
	@GetMapping("/{id}")
	public Checkout  getCheckoutById(@PathVariable int id) {
		return mapper.findById(id);
		
	}

	 @PostMapping
	public Checkout addCheckout(Checkout checkout) {
		mapper.save(checkout);
		return checkout;
		
	}
	 @PutMapping("/{id}")
	public  void updateCheckout(@PathVariable int id,
			@RequestBody Checkout checkout) {
		checkout.setId(id);
		mapper.update(checkout);
		
	}
	 @DeleteMapping("/{id}")
	public  void deleteCheckout(@PathVariable int id) {
		mapper.delete(id);
	
	

}
}
